//
//  PreferentialTableViewCell.m
//  carcar
//
//  Created by dlios on 15/9/12.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "PreferentialTableViewCell.h"

@implementation PreferentialTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.labelModelName = [[UILabel alloc]initWithFrame:CGRectMake(5 * suitableScreen_Width, 5 * suitableScreen_Width, 370 * suitableScreen_Width, 40 * suitableScreen_Width)];
        
        [self.labelModelName setNumberOfLines:0];
        
        [self.labelModelName setFont:[UIFont systemFontOfSize:18 * suitableScreen_Width]];
      
        [self.contentView addSubview:self.labelModelName];
       
        
        self.labelDelearName = [[UILabel alloc]initWithFrame:CGRectMake(5 *suitableScreen_Width, 45 * suitableScreen_Width, 200 * suitableScreen_Width, 40 * suitableScreen_Width)];
        [self.contentView addSubview:self.labelDelearName];
        [self.labelDelearName setFont:[UIFont systemFontOfSize:18 * suitableScreen_Width]];
        self.labelDelearName.alpha = 0.7 ; 
        self.cityLabel = [[UILabel alloc]initWithFrame:CGRectMake(5 * suitableScreen_Width, 85 * suitableScreen_Width, 100 * suitableScreen_Width, 25 * suitableScreen_Width)];
        [self.cityLabel setAlpha:0.7] ;
        [self.cityLabel setFont:[UIFont systemFontOfSize:12]];
        [self.contentView addSubview:self.cityLabel];
       
        self.numberLabel = [[ UILabel alloc]initWithFrame:CGRectMake(105 * suitableScreen_Width, 85 * suitableScreen_Width, 100 * suitableScreen_Width, 25 * suitableScreen_Width)];
        [self.numberLabel setAlpha:0.7];
        [self.numberLabel setFont:[UIFont systemFontOfSize:12]];
        [self.contentView addSubview:self.numberLabel];
               self.priceLabel  = [[UILabel alloc]initWithFrame:CGRectMake(270 * suitableScreen_Width, 45 * suitableScreen_Width, 100 * suitableScreen_Width, 40 * suitableScreen_Width)];
        [self.contentView addSubview:self.priceLabel];
        self.priceLabel.alpha = 0.7 ;
        
        self.declineLabel = [[UILabel alloc]initWithFrame:CGRectMake(270 * suitableScreen_Width , 85 * suitableScreen_Width, 100 * suitableScreen_Width, 25 * suitableScreen_Width)];
        [self.contentView addSubview:self.declineLabel];
        self.declineLabel.alpha = 0.7 ;
    
        self.buttonPhone = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.buttonPhone setFrame:CGRectMake(5 * suitableScreen_Width, 110 * suitableScreen_Width, 250 * suitableScreen_Width, 40 * suitableScreen_Width)];
        
        [self.buttonPhone setTitleColor:[UIColor colorWithRed:0.112 green:0.110 blue:1.000 alpha:1.000] forState:UIControlStateNormal];
        self.buttonPhone.titleLabel.font = [UIFont systemFontOfSize:18 * suitableScreen_Width];
        [self.buttonPhone.titleLabel setTextAlignment:NSTextAlignmentLeft];
        [self.contentView addSubview:self.buttonPhone];
       self.buttonCollect = [UIButton buttonWithType:UIButtonTypeCustom];
        self.buttonCollect.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.contentView addSubview:_buttonCollect];
        
        _buttonCollect.selected = NO ;
        
                 
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    
    return self ;
}


-(void)getPreModel:(PreferentialModel *)model
{
    
    [self.labelModelName setText:model.modelName];
    
    [self.labelDelearName setText:model.dealerName];
    
    
    NSMutableAttributedString * mutableString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@万",model.price]];
    
    NSInteger len = model.price.length ;
    
    [mutableString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, len)];
    self.declineLabel.attributedText = mutableString ;
    
    [self.buttonPhone setTitle:[NSString stringWithFormat:@"☎️电话咨询%@",model.phone] forState:UIControlStateNormal];
    
    NSMutableAttributedString * mutableString1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@万",model.decline]];
    
    NSInteger len1 = model.decline.length ;
    
    [mutableString1 addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, len1)];
    self.priceLabel.attributedText = mutableString1 ;
    
    
    self.priceLabel.attributedText = mutableString1 ;
    
    if (model.namelistRange == 3) {
        
        [self.cityLabel setText:@"售多市"];
        
        
    }
    else
    {
        [self.cityLabel setText:@"售少市"];
    }
    
    if (model.modelType == 1) {
        
        [self.numberLabel setText:@"现车充足"];
        
    }
    else{
        [self.numberLabel setText:@"现车不足"];
    }
    
    
    [self.buttonCollect setFrame:CGRectMake(270 * suitableScreen_Width, 110 * suitableScreen_Width, 100 * suitableScreen_Width, 40 * suitableScreen_Width)];

    [self.buttonCollect setTitle:@"收藏❤️" forState:UIControlStateNormal];
    [self.buttonCollect setTitle:@"取消❤️" forState:UIControlStateSelected];
    [_buttonCollect setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    [self.buttonCollect setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [self.buttonCollect setTitleColor:[UIColor redColor] forState:UIControlStateSelected];

}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
